import request from '@/utils/request'

export function login(_data) {
  const data = {
    userName:_data.username,
    password: _data.password,
    captcha: _data.captcha,
    uuid: _data.uuid
  }
  return request({
    url: '/login',
    method: 'post',
    data: data
  })
}
export function getInfo(token) {
  return request({
    url: '/getInfo',
    method: 'get',
  })
}

export function logout() {
  return request({
    url: '/vue-element-admin/user/logout',
    method: 'post'
  })
}
// 获取验证码
export function getCodeImg(uuid) {
  return request({
    url: `/captcha/image/${uuid}`,
    method: 'get',
    headers: {
      'Content-Type': 'application/json'
    },
  })
}
// 获取路由
export const getRouters = () => {
  return request({
    url: '/getRouters',
    method: 'get'
  })
}









// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: '/system/user/profile',
    method: 'get'
  })
}

// 修改用户个人信息
export function updateUserProfile(data) {
  return request({
    url: '/system/user/profile',
    method: 'put',
    data: data
  })
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return request({
    url: '/system/user/profile/updatePwd',
    method: 'put',
    params: data
  })
}

// 用户头像上传
export function uploadAvatar(data) {
  return request({
    url: '/system/user/profile/avatar',
    method: 'post',
    data: data
  })
}